package com.card.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.card.dao.CardHolderDao;
import com.card.dao.CardInfoMapper;
import com.card.entity.CardHolder;
import com.card.entity.CardInfo;
import com.card.service.CardHolderService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 名片夹
 */
@Service
public class CardHolderServiceImpl extends ServiceImpl<CardHolderDao, CardHolder> implements CardHolderService {

    @Resource
    private CardInfoMapper cardInfoMapper;

    @Override
    public void saveCard(Long id, String openId) {
        //获取名片信息
        CardInfo cardInfo = cardInfoMapper.selectById(id);
        CardHolder cardHolder = new CardHolder();
        cardHolder.setUserName(cardInfo.getUserName());
        cardHolder.setCompany(cardInfo.getCompany());
        cardHolder.setPosition(cardInfo.getPosition());
        cardHolder.setPhone(cardInfo.getPhone());
        cardHolder.setAddress(cardInfo.getAddress());
        cardHolder.setCardInfoOpenId(openId);
        baseMapper.insert(cardHolder);
    }
}

